<template>
  <div id="TesTing">
    <el-card class="box-card" style="margin:15px">
      <div style="margin-bottom:10px;display:flex">
        <el-button
          size="small"
          type="primary"
          icon="el-icon-document-checked"
          @click="clickCheck"
        >实验验收</el-button>
        <el-button
          size="small"
          type="primary"
          icon="el-icon-document-checked"
          @click="clickShaneCheck"
        >扫码验收</el-button>
        <el-button size="small" @click="getList()">刷新</el-button>
        <el-button size="small" type="primary" icon="el-icon-plus" @click="clickImportBut">导入样本数据</el-button>
      </div>
      <el-table
        :data="tableData"
        style="width: 100%;padding:5px;"
        :header-cell-style="{
          background: '#333333',
          color: '#ffffff',
          textAlign: 'center'
        }"
        ref="tableList"
        @selection-change="selectChanage"
      >
        <el-table-column align="center" type="selection" width="55" />
        <el-table-column align="center" prop="bloodArea" label="样本地区" />
        <el-table-column align="center" prop="deliveryId" label="递送批号" />
        <el-table-column align="center" prop="deliveryTime" label="递送日期">
          <template slot-scope="scope">
            <span>
              {{
              scope.row.deliveryTime ? scope.row.deliveryTime.substr(0, 10) : ""
              }}
            </span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="deliveryDepart" label="递送部门" show-overflow-tooltip />
        <el-table-column align="center" prop="deliveryMan" label="递送人员" />
        <el-table-column align="center" prop="bloodSum" label="总数" />
        <el-table-column align="center" prop="receiveNum" label="待验收数">
          <template slot-scope="scope">
            <span style="color:red">{{ scope.row.receiveNum }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="courier" label="快递人员" />
        <el-table-column align="center" prop="courierNum" label="快递单号" />
        <el-table-column align="center" prop="memo" label="备注" />
      </el-table>
      <el-pagination
        :current-page="basicData.current"
        :page-size="basicData.size"
        :total="total"
        layout="slot, total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
        <span
          v-if="tableData.length > 0"
          style="font-weight: 400;color:#606266"
        >已选中{{ selectList.length }}条，</span>
      </el-pagination>
    </el-card>

    <!-- 点击实验验收弹窗 -->
    <el-dialog
      :visible.sync="dialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      width="85%"
      title="实验验收"
      id="dialog-testing"
      @close="closeDialod"
    >
      <el-form
        ref="basicForm"
        :inline="true"
        :model="basicData"
        class="demo-form-inline"
        label-width="90px"
        :rules="basicDataRules"
        size="small"
        label-position="left"
        style="width:100%"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="初始编号:">
              <el-input size="mini" v-model="basicData.startNumber" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="条形码号:">
              <el-input
                size="mini"
                v-model="basicData.barCode"
                placeholder="输入"
                maxlength="11"
                @keyup.enter.native="queryBarCode"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="行号:" label-width="50px">
              <div class="flex">
                <el-input size="mini" v-model="basicData.start" placeholder="起始" />
                <span style="margin:0 10px">至</span>
                <el-input size="mini" v-model="basicData.end" placeholder="终止" />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="24" style="margin:10px 0">
            <div style="display: flex;align-items: flex-start;flex-direction: column;">
              <div>
                <el-button
                  size="mini"
                  type="primary"
                  style="margin-left: 15px !important"
                  @click="clickBianhao"
                >编号</el-button>
                <el-button size="mini" type="primary" @click="clickKJBH">快捷编号</el-button>
                <el-button size="mini" type="primary" @click="clickHospital()">医院</el-button>
                <el-button size="mini" type="primary" @click="clickExperiment()">项目</el-button>
                <el-button size="mini" type="primary" @click="TJShow =!TJShow">条件查询</el-button>
              </div>
            </div>
          </el-col>
        </el-row>
        <div v-if="TJShow">
          <el-row style="margin-bottom:10px !important">
            <el-col :span="4">
              <el-form-item label="实验编号:">
                <el-input size="mini" v-model="queryData.expNum" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="条形码号:">
                <el-input size="mini" v-model="queryData.barCode" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="母亲姓名:">
                <el-input size="mini" v-model="queryData.momName" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="性别:">
                <el-select v-model="queryData.babySex.key">
                  <el-option
                    :label="item"
                    :value="key"
                    v-for="(item, key, index) in dicts.BABY_SEX"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-button
                size="mini"
                type="primary"
                @click="clickResult"
                style="margin-left:15px  !important;"
              >重置</el-button>
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-folder-checked"
                @click="clickXZ"
              >选中</el-button>
            </el-col>
          </el-row>
        </div>
        <el-table
          v-loading="yanshouTableShow"
          ref="dormitoryTable"
          row-key="sampleId"
          :data="tables"
          stripe
          style="width: 100%;"
          :header-cell-style="{
          background: '#333333',
          color: '#ffffff',
          textAlign: 'center'
        }"
          class="import-table"
          @selection-change="selectDormitoryChanage"
          @row-dblclick="clickRows"
          @row-click="clickRow"
        >
          <el-table-column align="center" type="selection" width="45" />
          <el-table-column align="center" type="index" width="65" />
          <el-table-column align="center" label="实验编号" width="150" prop="expNum" />
          <el-table-column align="center" label="条形码号" width="150" prop="barCode" />
          <el-table-column align="center" label="母亲姓名" prop="momName" />
          <el-table-column align="center" label="性别" prop="babySex.data" />
          <el-table-column align="center" label="出生日期" width="100" prop="birthTime">
            <template slot-scope="scope">
              <span>
                {{
                scope.row.birthTime ? scope.row.birthTime.substr(0, 10) : ""
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="所属医院"
            prop="hospitalId.data.label"
            show-overflow-tooltip
          />
          <el-table-column align="center" label="实验项目" prop="experimentKeywords.data" />
          <el-table-column align="center" label="采血日期" width="100" prop="bloodTime">
            <template slot-scope="scope">
              <span>
                {{
                scope.row.bloodTime ? scope.row.bloodTime.substr(0, 10) : ""
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="合格" prop="qualified">
            <template slot-scope="scope">
              <el-checkbox v-model="scope.row.qualified" @change="changeQualified(scope.row)" />
            </template>
          </el-table-column>
          <el-table-column align="center" show-overflow-tooltip label="原因" prop="cause">
            <template slot-scope="scope" v-if="scope.row.qualified == false">
              <el-select
                size="mini"
                multiple
                v-model="scope.row.disqualificationReason"
                @change="changeDisqualificationReason(scope.row)"
                placeholder="不合格原因"
              >
                <el-option
                  :label="item"
                  :value="key"
                  v-for="(item, key, index) in dicts.DISQUALIFICATION_REASON"
                />
              </el-select>
            </template>
          </el-table-column>
          <el-table-column align="center" show-overflow-tooltip label="操作" prop="cause">
            <template slot-scope="scope">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-document-checked"
                @click="clickRows(scope.row)"
              >修改</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="display:flex;width:100%;margin:10px">
          <span>
            已选中
            <span style="color:blue;margin:0 5px">
              {{
              selectDormitoryList.length
              }}
            </span>
            条,共计{{ dormitory.length }}条结果
          </span>
        </div>
        <div style="width: 100%;">
          <!-- <el-form
          ref="basicForm"
          :inline="true"
          :model="basicData"
          :rules="basicDataRules"
          label-position="left"
          size="small"
          >-->
          <el-row>
            <el-col :span="8">
              <el-form-item label="验收人员:" prop="receiveMan">
                <el-input size="mini" v-model="basicData.receiveMan" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="验收部门:" prop="receiveDepart">
                <el-input size="mini" v-model="basicData.receiveDepart" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="验收日期:" prop="receiveTime">
                <el-date-picker
                  size="mini"
                  :format="receiveTimeFormat"
                  @focus="basicData.receiveTime = ''"
                  v-model="basicData.receiveTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="验收备注:" class="remark" prop="receiveDesc" label-width="80px">
                <el-input size="mini" v-model="basicData.receiveDesc" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="24" style="display:flex;justify-content: center;">
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-document-checked"
                @click="clickSeave"
              >验收</el-button>
            </el-col>
          </el-row>
        </div>
      </el-form>
    </el-dialog>

    <!-- 点击扫码验收弹窗 -->
    <el-dialog
      :visible.sync="showShane"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      width="85%"
      title="扫码验收"
      id="dialog-testing"
      @close="closeDialod"
    >
      <el-form
        ref="basicForm"
        :inline="true"
        :model="basicData"
        class="demo-form-inline"
        label-width="90px"
        :rules="basicDataRules"
        size="small"
        label-position="left"
        style="width:100%"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="初始编号:">
              <el-input size="mini" v-model="basicData.startNumber" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="条形码号:">
              <el-input
                size="mini"
                v-model="basicData.barCode"
                placeholder="输入"
                maxlength="11"
                @keyup.enter.native="queryBarCode"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="行号:" label-width="50px">
              <div class="flex">
                <el-input size="mini" v-model="basicData.start" placeholder="起始" />
                <span style="margin:0 10px">至</span>
                <el-input size="mini" v-model="basicData.end" placeholder="终止" />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="24" style="margin:10px 0">
            <div style="display: flex;align-items: flex-start;flex-direction: column;">
              <div>
                <el-button
                  size="mini"
                  type="primary"
                  style="margin-left: 15px !important"
                  @click="clickBianhao"
                >编号</el-button>
                <el-button size="mini" type="primary" @click="clickKJBHs">快捷编号</el-button>
                <el-button size="mini" type="primary" @click="clickHospital()">医院</el-button>
                <el-button size="mini" type="primary" @click="clickExperiment()">项目</el-button>
                <el-button size="mini" type="primary" @click="TJShow =!TJShow">条件查询</el-button>
              </div>
            </div>
          </el-col>
        </el-row>
        <div v-if="TJShow">
          <el-row style="margin-bottom:10px !important">
            <el-col :span="4">
              <el-form-item label="实验编号:">
                <el-input size="mini" v-model="queryData.expNum" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="条形码号:">
                <el-input size="mini" v-model="queryData.barCode" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="母亲姓名:">
                <el-input size="mini" v-model="queryData.momName" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="性别:">
                <el-select v-model="queryData.babySex.key">
                  <el-option
                    :label="item"
                    :value="key"
                    v-for="(item, key, index) in dicts.BABY_SEX"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-button
                size="mini"
                type="primary"
                @click="clickResult"
                style="margin-left:15px  !important;"
              >重置</el-button>
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-folder-checked"
                @click="clickXZ"
              >选中</el-button>
            </el-col>
          </el-row>
        </div>
        <el-table
          v-loading="yanshouTableShow"
          ref="dormitoryTable"
          row-key="sampleId"
          :data="tables"
          stripe
          style="width: 100%;"
          :header-cell-style="{
          background: '#333333',
          color: '#ffffff',
          textAlign: 'center'
        }"
          class="import-table"
          @selection-change="selectDormitoryChanage"
          @row-dblclick="clickRows"
          @row-click="clickRow"
        >
          <el-table-column align="center" type="selection" width="45" />
          <el-table-column align="center" type="index" width="65" />
          <el-table-column align="center" label="实验编号" width="150" prop="expNum" />
          <el-table-column align="center" label="条形码号" width="150" prop="barCode" />
          <el-table-column align="center" label="母亲姓名" prop="momName" />
          <el-table-column align="center" label="性别" prop="babySex.data" />
          <el-table-column align="center" label="出生日期" width="100" prop="birthTime">
            <template slot-scope="scope">
              <span>
                {{
                scope.row.birthTime ? scope.row.birthTime.substr(0, 10) : ""
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="所属医院"
            prop="hospitalId.data.label"
            show-overflow-tooltip
          />
          <el-table-column align="center" label="实验项目" prop="experimentKeywords.data" />
          <el-table-column align="center" label="采血日期" width="100" prop="bloodTime">
            <template slot-scope="scope">
              <span>
                {{
                scope.row.bloodTime ? scope.row.bloodTime.substr(0, 10) : ""
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="合格" prop="qualified">
            <template slot-scope="scope">
              <el-checkbox v-model="scope.row.qualified" @change="changeQualified(scope.row)" />
            </template>
          </el-table-column>
          <el-table-column align="center" show-overflow-tooltip label="原因" prop="cause">
            <template slot-scope="scope" v-if="scope.row.qualified == false">
              <el-select
                size="mini"
                multiple
                v-model="scope.row.disqualificationReason"
                @change="changeDisqualificationReason(scope.row)"
                placeholder="不合格原因"
              >
                <el-option
                  :label="item"
                  :value="key"
                  v-for="(item, key, index) in dicts.DISQUALIFICATION_REASON"
                />
              </el-select>
            </template>
          </el-table-column>
          <el-table-column align="center" show-overflow-tooltip label="操作" prop="cause">
            <template slot-scope="scope">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-document-checked"
                @click="clickRows(scope.row)"
              >修改</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="display:flex;width:100%;margin:10px">
          <span>
            已选中
            <span style="color:blue;margin:0 5px">
              {{
              selectDormitoryList.length
              }}
            </span>
            条,共计{{ dormitory.length }}条结果
          </span>
        </div>
        <div style="width: 100%;">
          <!-- <el-form
          ref="basicForm"
          :inline="true"
          :model="basicData"
          :rules="basicDataRules"
          label-position="left"
          size="small"
          >-->
          <el-row>
            <el-col :span="8">
              <el-form-item label="验收人员:" prop="receiveMan">
                <el-input size="mini" v-model="basicData.receiveMan" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="验收部门:" prop="receiveDepart">
                <el-input size="mini" v-model="basicData.receiveDepart" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="验收日期:" prop="receiveTime">
                <el-date-picker
                  size="mini"
                  :format="receiveTimeFormat"
                  @focus="basicData.receiveTime = ''"
                  v-model="basicData.receiveTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="验收备注:" class="remark" prop="receiveDesc" label-width="80px">
                <el-input size="mini" v-model="basicData.receiveDesc" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="24" style="display:flex;justify-content: center;">
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-document-checked"
                @click="clickSeave"
              >验收</el-button>
            </el-col>
          </el-row>
        </div>
      </el-form>
    </el-dialog>

    <!-- 点击数据导入 -->
    <el-dialog
      :visible.sync="importShow"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      id="dialog-testing-daoru"
      width="85%"
      title="数据导入"
    >
      <el-form
        ref="basicForm"
        :inline="true"
        :model="basicData"
        :rules="basicDataRules"
        class="demo-form-inline"
        label-width="90px"
        size="small"
        style="width:100%"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="初始编号:">
              <el-input size="mini" v-model="basicData.startNumber" placeholder="输入" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="条形码号:">
              <el-input
                size="mini"
                v-model="basicData.barCode"
                placeholder="输入"
                maxlength="11"
                @keyup.enter.native="queryBarCode"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="行号:">
              <div class="flex">
                <el-input size="mini" v-model="basicData.start" placeholder="起始" />
                <span style="margin:0 10px">至</span>
                <el-input size="mini" v-model="basicData.end" placeholder="终止" />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="6" style="display: flex;align-items: flex-start;">
            <div style="display: flex;align-items: flex-start;flex-direction: column;width:100%">
              <div style="width:100%">
                <el-button
                  size="mini"
                  type="primary"
                  style="margin-left: 15px !important;height:28px;width:25%;margin-right: 0 !important; "
                  @click="clickBianhao"
                >编号</el-button>
                <el-button
                  style="height:28px;width:25%;margin-right: 0 !important; "
                  size="mini"
                  type="primary"
                  @click="clickXZ"
                >选中</el-button>
                <el-button
                  style="height:28px;width:30%;margin-right: 0 !important; "
                  size="mini"
                  type="primary"
                  @click="clickKJBH"
                >快捷编号</el-button>
              </div>
            </div>
          </el-col>
          <el-col :span="24" style="margin-bottom:15px">
            <div style="display: flex;margin-top: 15px;">
              <el-button
                size="mini"
                type="primary"
                style="height:28px;width:60px;"
                @click="clickHospital()"
              >医院</el-button>
              <el-button
                style="height:28px;width:60px;"
                size="mini"
                type="primary"
                @click="clickExperiment()"
              >项目</el-button>
              <el-upload
                ref="upload"
                class="upload-demo"
                action
                :http-request="requestUpload"
                :on-change="onChange"
                :accept="'.xls, .xlsx'"
                :show-file-list="false"
              >
                <el-button style="height:28px;width:105px;" size="small" type="primary">导入样本数据</el-button>
              </el-upload>
              <el-button
                style="height:28px;width:105px;"
                size="mini"
                type="primary"
                @click="mordeStatus =!mordeStatus"
              >更多</el-button>
            </div>
          </el-col>
        </el-row>
        <div class="mores" v-if="mordeStatus">
          <div class="more-title">条件查询</div>
        </div>
        <el-row style="margin-bottom:10px !important" v-if="mordeStatus">
          <el-col :span="6">
            <el-form-item label="实验编号:">
              <el-input size="mini" v-model="queryData.expNum" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="条形码号:">
              <el-input size="mini" v-model="queryData.barCode" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="母亲姓名:">
              <el-input size="mini" v-model="queryData.momName" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="性别:">
              <el-select v-model="queryData.babySex.key">
                <el-option :label="item" :value="key" v-for="(item, key, index) in dicts.BABY_SEX" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button
              size="mini"
              type="primary"
              @click="clickResult"
              style="margin-left:15px  !important;"
            >重置</el-button>
          </el-col>
        </el-row>
        <!-- </el-form> -->
        <el-table
          v-loading="importTableShow"
          row-key="sampleId"
          ref="dormitoryTable"
          :data="tables"
          stripe
          style="width: 100%;"
          :header-cell-style="{
          background: '#333333',
          color: '#ffffff',
          textAlign: 'center'
        }"
          class="import-table"
          @selection-change="selectDormitoryChanage"
          @row-dblclick="clickRows"
          @row-click="clickRow"
        >
          <el-table-column align="center" type="selection" width="45" />
          <el-table-column align="center" type="index" width="65" />
          <el-table-column align="center" label="实验编号" width="150" prop="expNum" />
          <el-table-column align="center" label="条形码号" width="150" prop="barCode" />
          <el-table-column align="center" label="母亲姓名" prop="momName" />
          <el-table-column align="center" label="性别" prop="babySex.data" />
          <el-table-column align="center" label="出生日期" width="100" prop="birthTime">
            <template slot-scope="scope">
              <span>
                {{
                scope.row.birthTime ? scope.row.birthTime.substr(0, 10) : ""
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="所属医院"
            prop="hospitalId.data.label"
            show-overflow-tooltip
          />
          <el-table-column align="center" label="实验项目" prop="experimentKeywords.data" />
          <el-table-column align="center" label="采血日期" width="100" prop="bloodTime">
            <template slot-scope="scope">
              <span>
                {{
                scope.row.bloodTime ? scope.row.bloodTime.substr(0, 10) : ""
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="合格" prop="qualified">
            <template slot-scope="scope">
              <el-checkbox v-model="scope.row.qualified" @change="changeQualified(scope.row)" />
            </template>
          </el-table-column>
          <el-table-column align="center" show-overflow-tooltip label="原因" prop="cause">
            <template slot-scope="scope" v-if="scope.row.qualified == false">
              <el-select
                size="mini"
                multiple
                v-model="scope.row.disqualificationReason"
                @change="changeDisqualificationReason(scope.row)"
                placeholder="不合格原因"
              >
                <el-option
                  :label="item"
                  :value="key"
                  v-for="(item, key, index) in dicts.DISQUALIFICATION_REASON"
                />
              </el-select>
            </template>
          </el-table-column>
          <el-table-column align="center" show-overflow-tooltip label="操作" prop="cause">
            <template slot-scope="scope">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-document-checked"
                @click="clickRows(scope.row)"
              >修改</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="display:flex;width:100%;margin:10px">
          <span>
            已选中
            <span style="color:blue;margin:0 5px">
              {{
              selectDormitoryList.length
              }}
            </span>
            条,共计{{ dormitory.length }}条结果
          </span>
        </div>
        <div style="width: 100%;">
          <!-- <el-form
          ref="basicForm"
          :inline="true"
          :model="basicData"
          :rules="basicDataRules"
          class="demo-form-inline"
          label-width="120px"
          size="small"
          >-->
          <el-row>
            <el-col :span="8">
              <el-form-item label="验收人员:" prop="receiveMan">
                <el-input size="mini" v-model="basicData.receiveMan" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="验收部门:" prop="receiveDepart">
                <el-input size="mini" v-model="basicData.receiveDepart" placeholder="输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="验收日期:" prop="receiveTime">
                <el-date-picker
                  size="mini"
                  :format="receiveTimeFormat"
                  @focus="basicData.receiveTime = ''"
                  v-model="basicData.receiveTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="验收备注:" class="remark" prop="receiveDesc" label-width="80px">
                <el-input
                  size="mini"
                  v-model="basicData.receiveDesc"
                  type="textarea"
                  placeholder="输入"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <div class="flex">
            <el-button
              size="small"
              type="primary"
              icon="el-icon-document-checked"
              @click="clickSeave"
            >验收</el-button>
          </div>
        </div>
      </el-form>
    </el-dialog>

    <!-- 所属医院修改 -->
    <el-dialog
      width="65%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      title="所属医院修改"
      :visible.sync="HospitalShow"
      append-to-body
    >
      <el-form
        ref="basicForm"
        :inline="true"
        :model="hospitalItem"
        size="small"
        label-width="100px"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="所属区县:" prop="areaId.key">
              <el-select
                size="mini"
                v-model="hospitalItem.areaId.key"
                placeholder="选择"
                @change="clickOrgTree"
              >
                <el-option
                  v-for="(item, index) in orgTree"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属医院:" prop="hospitalId.key">
              <el-select
                size="mini"
                v-model="hospitalItem.hospitalId.key"
                placeholder="选择"
                @change="clickOrgTreeC"
              >
                <el-option
                  v-for="(item, index) in orgTreeC"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属部门:" prop="departId.key">
              <el-select size="mini" v-model="hospitalItem.departId.key" placeholder="选择">
                <el-option
                  v-for="(item, index) in orgTreeCs"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="flex" style="margin-top:20px">
        <el-button
          size="small"
          type="primary"
          icon="el-icon-document-checked"
          @click="hospitalSave"
        >保存</el-button>
        <el-button size="small" @click="HospitalShow = false">关闭</el-button>
      </div>
    </el-dialog>

    <!-- 实验项目修改 -->
    <el-dialog
      width="65%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      title="实验项目修改"
      :visible.sync="ExperimentShow"
      append-to-body
    >
      <el-form
        ref="basicForm"
        :inline="true"
        :model="experimentItem"
        size="small"
        label-width="100px"
      >
        <el-row>
          <el-col id="shiyan" :span="24" class="more-col">
            <el-form-item label="实验项目:" prop="projectIdList" class="projectIdList">
              <el-checkbox-group v-model="experimentItem.experimentProjects">
                <el-checkbox
                  v-for="(item, key, index) in dicts.EXPERIMENT_CODE"
                  :label="key"
                  name="type"
                >{{ item }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="flex" style="margin-top:20px">
        <el-button
          size="small"
          type="primary"
          icon="el-icon-document-checked"
          @click="experimentSave"
        >保存</el-button>
        <el-button size="small" @click="ExperimentShow = false">关闭</el-button>
      </div>
    </el-dialog>

    <!-- 样本修改 -->
    <el-dialog
      width="85%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      title="样本修改"
      :visible.sync="innerVisible"
      append-to-body
      class="edit-sample"
    >
      <el-form
        ref="basicForm"
        :rules="sampleDataRules"
        :inline="true"
        :model="sampleData"
        size="small"
        label-width="125px"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="所属区县:" prop="areaId.key">
              <el-select
                size="mini"
                v-model="sampleData.areaId.key"
                placeholder="选择"
                @change="clickOrgTree"
              >
                <el-option
                  v-for="(item, index) in orgTree"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属医院:" prop="hospitalId.key">
              <el-select
                size="mini"
                v-model="sampleData.hospitalId.key"
                placeholder="选择"
                @change="clickOrgTreeC"
              >
                <el-option
                  v-for="(item, index) in orgTreeC"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属部门:" prop="departId.key">
              <el-select size="mini" v-model="sampleData.departId.key" placeholder="选择">
                <el-option
                  v-for="(item, index) in orgTreeCs"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6"></el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="母亲姓名:" prop="momName">
              <el-input size="mini" v-model="sampleData.momName" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="母亲身份证:" prop="momCard">
              <el-input size="mini" v-model="sampleData.momCard" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="父亲身份证:" prop="dadCard">
              <el-input size="mini" v-model="sampleData.dadCard" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="手机号码:" prop="phone">
              <el-input
                size="mini"
                v-model="sampleData.phone"
                placeholder="输入"
                type="text"
                maxlength="11"
                oninput="value=value.replace(/[^\d.]/g,'')"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="母亲户籍:" prop="momCensus">
              <el-radio-group v-model="sampleData.momCensus.key">
                <el-radio
                  v-for="(item, key, index) in dicts.MOM_CENSUS"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="住址:" prop="address">
              <el-input size="mini" v-model="sampleData.address" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="婴儿体重:" prop="weight">
              <el-input
                size="mini"
                v-model="sampleData.weight"
                type="text"
                oninput="value=value.replace(/[^\d.]/g,'')"
                placeholder="输入"
              >
                <template slot="append">克</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="孕周:" prop="weeks">
              <el-input
                size="mini"
                v-model="sampleData.weeks"
                type="text"
                oninput="value=value.replace(/[^\d.]/g,'')"
                placeholder="输入"
              >
                <template slot="append">周</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="孕天:" prop="days">
              <el-input
                size="mini"
                v-model="sampleData.days"
                placeholder="输入"
                type="text"
                oninput="value=value.replace(/[^\d.]/g,'')"
              >
                <template slot="append">天</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="户口类型:" prop="accountType">
              <el-radio-group v-model="sampleData.accountType.key">
                <el-radio
                  v-for="(item, key, index) in dicts.ACCOUNT_TYPE"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出生日期:" prop="birthTime">
              <el-date-picker
                :format="birthTimeFormat"
                @focus="sampleData.birthTime = ''"
                v-model="sampleData.birthTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="性别:" prop="babySex">
              <el-radio-group v-model="sampleData.babySex.key">
                <el-radio
                  v-for="(item, key, index) in dicts.BABY_SEX"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="采血编号:" prop="bloodNum">
              <el-input size="mini" v-model="sampleData.bloodNum" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="条形码号:" prop="barCode">
              <el-input size="mini" v-model="sampleData.barCode" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="样本质量:" prop="sampleQuality">
              <el-select size="mini" v-model="sampleData.sampleQuality.key" placeholder="样本质量">
                <el-option
                  v-for="(item, key, index) in dicts.SAMPLE_QUALITY"
                  :key="item"
                  :label="item"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采血人:" prop="samplingPeople">
              <el-input size="mini" v-model="sampleData.samplingPeople" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="采血日期:" prop="bloodTime">
              <el-date-picker
                size="mini"
                :format="bloodTimeFormat"
                @focus="sampleData.bloodTime = ''"
                v-model="sampleData.bloodTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col id="shiyan" :span="24" class="more-col">
            <el-form-item label="实验项目:" prop="projectIdList" class="projectIdList">
              <el-checkbox-group v-model="sampleData.experimentProject">
                <el-checkbox
                  v-for="(item, key, index) in dicts.EXPERIMENT_CODE"
                  :label="key"
                  name="type"
                >{{ item }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="费用类型:" prop="costType">
              <el-radio-group v-model="sampleData.costType.key">
                <el-radio
                  v-for="(item, key, index) in dicts.COST_TYPE"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="送检医生:" prop="getexamineDoctor">
              <el-input size="mini" v-model="sampleData.getexamineDoctor" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="实验编号:" prop="expNum">
              <el-input size="mini" v-model="sampleData.expNum" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="免费券号:" prop="freeNum">
              <el-input size="mini" v-model="sampleData.freeNum" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24" class="more-col" id="more-row">
            <el-form-item label="筛查备注:" class="remark" prop="remark">
              <el-input size="mini" v-model="sampleData.remark" type="textarea" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="flex" style="margin-top:20px">
        <el-button
          size="small"
          type="primary"
          icon="el-icon-document-checked"
          @click="editSemperSave"
        >保存</el-button>
        <el-button size="small" @click="innerVisible = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { initDicts } from "@/utils/commons";
import DeliveryManageApi from "@/api/DeliveryManage.js";
import userApi from "@/api/User.js";
import importSampleApi from "@/api/importSample.js";
import orgApi from "@/api/Org.js";

export default {
  data() {
    return {
      receiveTimeFormat: "yyyy-MM-dd",
      birthTimeFormat: "MMdd",
      bloodTimeFormat: "MMdd",
      // 医院弹窗
      HospitalShow: false,
      TJShow: false,
      mordeStatus: false,
      // 医院保存数据
      hospitalItem: {
        areaId: {
          key: ""
        },
        departId: {
          key: ""
        },
        hospitalId: {
          key: ""
        },
        sampleIds: []
      },
      // 项目弹窗
      ExperimentShow: false,
      // 项目保存数据
      experimentItem: {
        experimentProjects: [],
        sampleIds: []
      },
      // 验收、导入查询数据
      queryData: {
        expNum: "",
        barCode: "",
        momName: "",
        babySex: {
          key: "",
          data: ""
        }
      },
      // 验收弹窗
      dialog: false,
      // 扫码验收弹窗
      showShane: false,
      // 验收表格转菊花
      yanshouTableShow: false,
      // 扫码验收表格转菊花
      shaneTableShow: false,
      // 导入弹窗
      importShow: false,
      // 修改样本弹窗
      innerVisible: false,
      // 详情表格
      importTableShow: false,
      // 修改样本数据
      sampleData: {
        // 户口类型【农村/城镇】
        accountType: {
          key: "village"
        },
        // 住址
        address: "",
        // 所属区县
        areaId: {
          key: ""
        },
        // 婴儿性别【男/女/未知】
        babySex: {
          key: "boy"
        },
        // 条形码号
        barCode: "",
        // 出生日期
        birthTime: "",
        // 采血编号
        bloodNum: "",
        // 采血日期
        bloodTime: "",
        // 费用类型【自费/免费】
        costType: {
          key: "selfpaying"
        },
        // 父亲身份证
        dadCard: "",
        // 孕天【0-6之间】
        days: "",
        // 所属部门
        departId: {
          key: ""
        },
        // 实验编号
        expNum: "",
        // 免费劵号
        freeNum: "",
        // 送检医生
        getexamineDoctor: "",
        // 医院id
        hospitalId: {
          key: ""
        },
        // 母亲身份证
        momCard: "",
        // 母亲户籍【本地/外地】
        momCensus: {
          key: "native"
        },
        // 母亲姓名
        momName: "",
        // 手机号码
        phone: "",
        // 筛查备注
        remark: "",
        // 样本质量【默认合格，基础码表】
        sampleQuality: {
          key: ""
        },
        // 采血人
        samplingPeople: "",
        // 孕周【20-50之间】
        weeks: "",
        // 婴儿体重
        weight: "",
        // 实验项目
        experimentProject: []
      },
      //实验项目:层级太深报错，单独抽出来
      projectIdList: ["PHE", "TSH", "17_a_0HP", "G6PD", "MSMS"],
      // 修改样本数据验证
      sampleDataRules: {
        "areaId.key": [{ required: true, message: "必填", trigger: "change" }],
        "hospitalId.key": [
          { required: true, message: "必填", trigger: "change" }
        ],
        "departId.key": [
          { required: true, message: "必填", trigger: "change" }
        ],
        momName: [{ required: true, message: "必填", trigger: "change" }],
        phone: [
          { required: true, message: "必填", trigger: "change" },
          {
            required: true,
            pattern: /^1[3456789]\d{9}$/,
            message: "请输入正确格式的手机号",
            trigger: "blur"
          }
        ],
        weight: [
          { required: true, message: "必填", trigger: "change" },
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            required: true,
            validator: this.$weightNum,
            trigger: "blur",
            message: "请输入600—8000的数字"
          }
        ],
        weeks: [
          { required: true, message: "必填", trigger: "change" },
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            required: true,
            validator: this.$weeksNum,
            trigger: "blur",
            message: "请输入20—50的数字"
          }
        ],
        // days: [
        //   { required: true, message: "必填", trigger: "change" },
        //   {
        //     pattern: /^[0-9]*$/,
        //     message: "请填写正确格式的数字",
        //     trigger: "change"
        //   },
        //   {
        //     required: true,
        //     validator: this.$daysNum,
        //     trigger: "blur",
        //     message: "请输入0—6的数字"
        //   }
        // ],
        birthTime: [{ required: true, message: "  ", trigger: "change" }],
        bloodTime: [{ required: true, message: "  ", trigger: "change" }],
        babySex: [{ required: true, message: "  ", trigger: "change" }],
        barCode: [
          {
            required: true,
            message: "必填",
            trigger: "change"
          },
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            required: true,
            validator: this.$barCodeNum,
            trigger: "blur",
            message: "请输入14000000000—20999999999的数字"
          }
        ],
        costType: [{ required: true, message: "  ", trigger: "change" }],
        dadCard: [
          {
            pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
            message: "身份证号格式错误",
            trigger: "change"
          }
        ],
        momCard: [
          {
            pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
            message: "身份证号格式错误",
            trigger: "change"
          }
        ],
        freeNum: [
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            validator: this.$freeNum,
            message: "请输入200110001—200145000的数字",
            trigger: "change"
          }
        ]
      },
      // 市县
      orgTree: [],
      // 医院
      orgTreeC: [],
      // 部门
      orgTreeCs: [],
      // 是否展示更多信息
      morderShow: true,
      total: 0,
      // 表格数据
      tableData: [],
      ///////////////////////////////////////
      // 弹窗form表单数据
      basicData: {
        // 初始编号
        startNumber: "",
        // 条形码号
        barCode: "",
        // 起始
        start: "",
        // 终止
        end: "",
        // 验收人员
        receiveMan: this.$store.state.account.user.name,
        // 验收日期
        receiveTime:
          new Date().getFullYear().toString() +
          "-" +
          ((new Date().getMonth() + 1).toString() < 10
            ? "0" + (new Date().getMonth() + 1).toString()
            : (new Date().getMonth() + 1).toString()) +
          "-" +
          (new Date().getDate().toString() < 10
            ? "0" + new Date().getDate().toString()
            : new Date().getDate().toString()),
        // 验收部门
        receiveDepart: "",
        // 验收备注
        receiveDesc: ""
      },
      basicDataRules: {
        receiveMan: [{ required: true, message: "   ", trigger: "change" }],
        receiveTime: [{ required: true, message: "   ", trigger: "change" }],
        receiveDepart: [{ required: true, message: "   ", trigger: "change" }]
      },
      // 弹窗表格
      dormitory: [],
      // 弹窗表格过滤
      queryItem: {},
      // 选中数据
      selectList: [],
      // 选中详情表格数据
      selectDormitoryList: [],
      // 字典
      dicts: {
        DISQUALIFICATION_REASON: {}, //不合格原因
        MOM_CENSUS: {}, //母亲户籍
        BABY_SEX: {}, //婴儿性别
        ACCOUNT_TYPE: {}, //户口类型
        SAMPLE_QUALITY: {}, //样本质量
        EXPERIMENT_CODE: {}, //实验项目
        COST_TYPE: {} //费用类型
      },
      // 文件
      file: {},
      inExpData: {
        bloodArea: "",
        deliveryDepart: "",
        deliveryId:
          new Date().getFullYear().toString() +
          ((new Date().getMonth() + 1).toString() < 10
            ? "0" + (new Date().getMonth() + 1).toString()
            : (new Date().getMonth() + 1).toString()) +
          (new Date().getDate().toString() < 10
            ? "0" + new Date().getDate().toString()
            : new Date().getDate().toString()) +
          new Date().getHours().toString() +
          new Date().getMinutes().toString() +
          new Date().getSeconds().toString(),
        deliveryMan: this.$store.state.account.user.name,
        deliveryTime:
          new Date().getFullYear().toString() +
          "-" +
          ((new Date().getMonth() + 1).toString() < 10
            ? "0" + (new Date().getMonth() + 1).toString()
            : (new Date().getMonth() + 1).toString()) +
          "-" +
          (new Date().getDate().toString() < 10
            ? "0" + new Date().getDate().toString()
            : new Date().getDate().toString())
      },
      importDeliveryId: ""
    };
  },
  mounted() {
    initDicts(
      [
        "DISQUALIFICATION_REASON",
        "MOM_CENSUS",
        "BABY_SEX",
        "ACCOUNT_TYPE",
        "SAMPLE_QUALITY",
        "COST_TYPE",
        "EXPERIMENT_CODE"
      ],
      this.dicts
    );
    this.getList();
    // 获取基础查询
    this.initOrgTree();
  },
  computed: {
    // 模糊搜索
    tables() {
      if (this.dormitory.length > 0) {
        let dataList = JSON.parse(JSON.stringify(this.dormitory));
        let queryList = [];
        if (this.queryData.expNum != "") {
          let i = 0;
          dataList.filter(data => {
            Object.keys(data).some(key => {
              if (key == "expNum") {
                if (
                  String(data[key])
                    .toLowerCase()
                    .indexOf(this.queryData.expNum) > -1
                ) {
                  queryList.push(data);
                  i++;
                }
              }
            });
          });
          if (i == 0) {
            this.$message.error("没有当前实验编号");
          }
        } else if (this.queryData.barCode != "") {
          dataList.filter(data => {
            Object.keys(data).some(key => {
              if (key == "barCode") {
                if (
                  String(data[key])
                    .toLowerCase()
                    .indexOf(this.queryData.barCode) > -1
                ) {
                  queryList.push(data);
                }
              }
            });
          });
        } else if (this.queryData.momName != "") {
          dataList.filter(data => {
            Object.keys(data).some(key => {
              if (key == "momName") {
                if (
                  String(data[key])
                    .toLowerCase()
                    .indexOf(this.queryData.momName) > -1
                ) {
                  queryList.push(data);
                }
              }
            });
          });
        } else if (this.queryData.babySex.key != "") {
          dataList.filter(data => {
            Object.keys(data).some(key => {
              if (key == "babySex") {
                if (
                  String(data[key].key)
                    .toLowerCase()
                    .indexOf(this.queryData.babySex.key) > -1
                ) {
                  queryList.push(data);
                }
              }
            });
          });
        } else {
          queryList = JSON.parse(JSON.stringify(this.dormitory));
        }

        return queryList;
      }
    }
  },
  methods: {
    // 扫码验收
    getscanReceive() {
      DeliveryManageApi.acceptanceTesting
        .scanReceive({
          barCode: this.basicData.barCode
        })
        .then(res => {
          if (res.data.msg == "该样本还未递送，请先递送！") {
            this.$confirm("样本未曾递送，是否递送?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(() => {
              let data = {
                barCode: this.basicData.barCode,
                userName: this.$store.state.account.user.name
              };
              DeliveryManageApi.acceptanceTesting.updFlow(data).then(updRes => {
                DeliveryManageApi.acceptanceTesting
                  .scanReceive({
                    barCode: this.basicData.barCode
                  })
                  .then(scanRes => {
                    if (this.dormitory.length > 0) {
                      let i = 0;
                      this.dormitory.forEach((item, index) => {
                        if (
                          this.dormitory[index].barCode.indexOf(
                            this.basicData.barCode
                          ) > -1
                        ) {
                          i++;
                        }
                      });
                      if (i == 0) {
                        scanRes.data.data.qualified = true;
                        this.dormitory.push(scanRes.data.data);
                      } else {
                        this.$message.error("这张血卡已经扫过了哦~");
                      }
                    } else {
                      scanRes.data.data.qualified = true;
                      this.dormitory.push(scanRes.data.data);
                    }
                  });
              });
            });
          } else {
            if (this.dormitory.length > 0) {
              let i = 0;
              this.dormitory.forEach((item, index) => {
                if (
                  this.dormitory[index].barCode.indexOf(
                    this.basicData.barCode
                  ) > -1
                ) {
                  i++;
                }
              });
              if (i == 0) {
                res.data.data.qualified = true;
                this.dormitory.push(res.data.data);
              } else {
                this.$message.error("这张血卡已经扫过了哦~");
              }
            } else {
              res.data.data.qualified = true;
              this.dormitory.push(res.data.data);
            }
          }
        });
    },
    // 验收日期输入
    changeReceiveTime(v) {
      this.basicData.receiveTime = v;
      if (this.basicData.receiveTime) {
        this.receiveTimeFormat = "yyyy-MM-dd";
      } else {
        this.receiveTimeFormat = "MMdd";
      }
    },
    // 出生日期输入
    changeBirthTime(v, type) {
      this.sampleData.birthTime = v;
      if (this.sampleData.birthTime) {
        this.birthTimeFormat = "yyyy-MM-dd";
      } else {
        this.birthTimeFormat = "MMdd";
      }
    },
    // 采血日期输入
    changeBloodTime(v, type) {
      this.sampleData.bloodTime = v;
      if (this.sampleData.bloodTime) {
        this.bloodTimeFormat = "yyyy-MM-dd";
      } else {
        this.bloodTimeFormat = "MMdd";
      }
    },
    // 点击医院
    clickHospital() {
      if (this.selectDormitoryList.length > 0) {
        this.HospitalShow = true;
        this.hospitalItem = {
          areaId: {
            key: ""
          },
          departId: {
            key: ""
          },
          hospitalId: {
            key: ""
          },
          sampleIds: []
        };
        let data = [];
        this.selectDormitoryList.forEach(item => {
          data.push(item.sampleId);
        });
        this.hospitalItem.sampleIds = data;
      } else {
        this.$message.error("请选择数据");
        return;
      }
    },
    // 医院保存
    hospitalSave() {
      DeliveryManageApi.acceptanceTesting
        .updHospital(this.hospitalItem)
        .then(res => {
          if (res.status === 200) {
            this.$message({
              type: "success",
              message: res.statusText
            });
            this.yanshouTableShow = true;
            DeliveryManageApi.acceptanceTesting
              .selectSampleDetail({ deliveryId: this.selectList[0].deliveryId })
              .then(res => {
                if (res.status === 200) {
                  this.dormitory = res.data.data.list;
                  this.dormitory.forEach(item => {
                    item.qualified = true;
                    item.disqualificationReason = [];
                  });
                } else {
                  this.$message.error(res.statusText);
                }
              })
              .finally(() => ((this.yanshouTableShow = false), this.clickXZ()));
          } else {
            this.$message.error(res.statusText);
          }
        })
        .finally(() => (this.HospitalShow = false));
    },
    // 点击项目
    clickExperiment() {
      if (this.selectDormitoryList.length > 0) {
        this.ExperimentShow = true;
        this.experimentItem = {
          experimentProjects: [],
          sampleIds: []
        };
        let data = [];
        this.selectDormitoryList.forEach(item => {
          data.push(item.sampleId);
        });
        this.experimentItem.sampleIds = data;
      } else {
        this.$message.error("请选择数据");
        return;
      }
    },
    // 项目保存
    experimentSave() {
      DeliveryManageApi.acceptanceTesting
        .updExperiment(this.experimentItem)
        .then(res => {
          if (res.status === 200) {
            this.$message({
              type: "success",
              message: res.statusText
            });

            this.yanshouTableShow = true;
            DeliveryManageApi.acceptanceTesting
              .selectSampleDetail({ deliveryId: this.selectList[0].deliveryId })
              .then(res => {
                if (res.status === 200) {
                  this.dormitory = res.data.data.list;
                  this.dormitory.forEach(item => {
                    item.qualified = true;
                    item.disqualificationReason = [];
                  });
                } else {
                  this.$message.error(res.statusText);
                }
              })
              .finally(() => ((this.yanshouTableShow = false), this.clickXZ()));
          } else {
            this.$message.error(res.statusText);
          }
        })
        .finally(() => (this.ExperimentShow = false));
    },
    // 重置搜索
    clickResult() {
      this.queryData = {
        expNum: "",
        barCode: "",
        momName: "",
        babySex: {
          key: "",
          data: ""
        }
      };
    },
    // 获取基础查询
    initOrgTree() {
      orgApi.allTree({}).then(response => {
        const res = response.data;
        this.orgTree = res.data[0].children;
      });
    },
    // 根据选择市县获取医院
    clickOrgTree(v) {
      this.orgTreeC = [];
      this.orgTreeCs = [];
      this.hospitalItem.hospitalId.key = "";
      this.hospitalItem.departId.key = "";
      this.sampleData.hospitalId.key = "";
      this.sampleData.departId.key = "";
      this.orgTree.filter(res => {
        if (res.id == v) {
          this.orgTreeC = res.children;
        }
      });
    },
    // 根据选择市县获取医院
    clickOrgTreeC(v) {
      this.orgTreeCs = [];
      this.hospitalItem.departId.key = "";
      this.sampleData.departId.key = "";
      this.orgTreeC.filter(res => {
        if (res.id == v) {
          this.orgTreeCs = res.children;
        }
      });
    },
    // 上传文件
    onChange(file) {
      this.file = file.raw;
    },
    // 修改上传文件地址
    requestUpload(file) {
      let that = this;
      //  表单提交方式
      let FormDatas = new FormData();
      that.importTableShow = true;
      FormDatas.append("file", that.file);
      importSampleApi.applayList
        .importFile(FormDatas)
        .then(function(res) {
          if (res.data.isSuccess) {
            that.dormitory = res.data.data;
            that.dormitory.forEach(item => {
              item.qualified = true;
              item.disqualificationReason = [];
              // that.$refs.dormitoryTable.toggleRowSelection(item); //选中
            });
          } else {
            that.$message.error(res.data.data.msg);
          }
        })
        .finally(() => ((this.importTableShow = false), this.clickXZ()));
    },
    // 点击验收
    clickSeave() {
      this.$refs.basicForm.validate(valid => {
        if (valid) {
          if (this.selectDormitoryList.length == 0) {
            this.$message.error("未选中待验收样本");
            return;
          }
          let count = 0;
          this.selectDormitoryList.forEach(item => {
            if (item.expNum) {
              count++;
            }
          });
          if (count == this.selectDormitoryList.length) {
            let data = {
              list: [],
              saveDTO: {
                receiveDepart: this.basicData.receiveDepart,
                receiveDesc: this.basicData.receiveDesc,
                receiveMan: this.basicData.receiveMan,
                receiveTime: this.basicData.receiveTime
              }
            };
            this.selectDormitoryList.forEach((item, index) => {
              data.list[index] = {
                barCode: item.barCode ? item.barCode : "",
                deliveryId: item.deliveryId ? item.deliveryId : "",
                disqualificationReason: item.disqualificationReason
                  ? item.disqualificationReason
                  : [],
                expNum: item.expNum ? item.expNum.toString() : "",
                qualified: item.qualified ? item.qualified : false,
                sampleId: item.sampleId ? item.sampleId : ""
              };
            });

            DeliveryManageApi.acceptanceTesting
              .sampleReceive(data)
              .then(res => {
                if (res.status === 200) {
                  this.$message({
                    type: "success",
                    message: res.statusText
                  });
                  this.getList();
                  this.dialog = false;
                  this.showShane = false;
                } else {
                  this.$message.error(res.statusText);
                }
              })
              .finally(
                () => ((this.loading = false), (this.importShow = false))
              );
          } else {
            this.$message.error("请编写实验编号");
          }
        } else {
          return false;
        }
      });
    },
    // 选择合格不合格
    changeQualified(row) {
      if (row.qualified == true) {
        row.disqualificationReason = [];
      }
      this.dormitory.forEach((item, index) => {
        if (item.sampleId == row.sampleId) {
          this.$set(this.dormitory, index, row);
        }
      });
    },
    // 选择不合格原因
    changeDisqualificationReason(row) {
      this.dormitory.forEach((item, index) => {
        if (item.sampleId == row.sampleId) {
          this.$set(this.dormitory, index, row);
        }
      });
    },
    // 关闭窗口
    closeDialod() {
      this.$refs.tableList.clearSelection();
      this.queryItem = {};
      this.selectDormitoryList = [];
      this.basicData = {
        // 初始编号
        startNumber: "",
        // 条形码号
        barCode: "",
        // 起始
        start: "",
        // 终止
        end: "",
        // 验收人员
        receiveMan: this.$store.state.account.user.name,
        // 验收日期
        receiveTime:
          new Date().getFullYear().toString() +
          "-" +
          ((new Date().getMonth() + 1).toString() < 10
            ? "0" + (new Date().getMonth() + 1).toString()
            : (new Date().getMonth() + 1).toString()) +
          "-" +
          (new Date().getDate().toString() < 10
            ? "0" + new Date().getDate().toString()
            : new Date().getDate().toString()),
        // 验收部门
        receiveDepart: "",
        // 验收备注
        receiveDesc: ""
      };
      this.getList();
    },
    // 点击编号
    clickBianhao() {
      let row = {};
      let addNumb = JSON.stringify(JSON.parse(this.basicData.startNumber));
      if (this.basicData.start != "" && this.basicData.end != "") {
        if (this.basicData.start > this.basicData.end) {
          this.$message.error("终止行号需大于起始行号");
          return;
        } else {
          if (addNumb == "") {
            this.$message.error("请输入初始编号");
            return;
          }
          for (
            let index = Number(this.basicData.start) - 1;
            index < this.basicData.end;
            index++
          ) {
            this.dormitory[index].expNum = Number(addNumb++);
            row = this.dormitory[index];
            this.$set(this.dormitory, index, row);
          }
        }
      } else if (this.basicData.start != "") {
        if (addNumb == "") {
          this.$message.error("请输入初始编号");
          return;
        }
        for (
          let index = Number(this.basicData.start) - 1;
          index < this.dormitory.length;
          index++
        ) {
          this.dormitory[index].expNum = Number(addNumb++);
          row = this.dormitory[index];
          this.$set(this.dormitory, index, row);
        }
      } else if (this.basicData.end != "") {
        if (addNumb == "") {
          this.$message.error("请输入初始编号");
          return;
        }
        for (let index = 0; index < Number(this.basicData.end); index++) {
          this.dormitory[index].expNum = Number(addNumb++);
          row = this.dormitory[index];
          this.$set(this.dormitory, index, row);
        }
      } else {
        if (addNumb == "") {
          this.$message.error("请输入初始编号");
          return;
        }
        this.dormitory.forEach((item, index) => {
          item.expNum = Number(addNumb++);
          row = item;
          this.$set(this.dormitory, index, row);
        });
      }
    },
    // 选中
    clickXZ() {
      this.tables.forEach((item, index) => {
        this.$refs.dormitoryTable.toggleRowSelection(item); //选中
      });
    },
    // 快捷编号
    clickKJBH() {
      let row = {};
      if (this.basicData.barCode != "") {
        this.dormitory.forEach((item, index) => {
          if (item.barCode == this.basicData.barCode) {
            item.expNum = this.basicData.barCode;
          }
          row = item;
          this.$set(this.dormitory, index, row);
        });
      } else {
        this.dormitory.forEach((item, index) => {
          item.expNum = item.barCode;
          row = item;
          this.$set(this.dormitory, index, row);
        });
      }
    },
    // 快捷编号
    clickKJBHs() {
      this.tables.forEach((item, index) => {
        item.expNum = item.barCode;
        this.clickRow(item);
      });
    },
    // 详情-根据输入条形码号过滤
    queryBarCode() {
      this.tables.filter((item, index) => {
        if (item.barCode == this.basicData.barCode) {
          this.queryItem = item;
          this.basicData.barCode = "";
          this.$refs.dormitoryTable.toggleRowSelection(item); //选中
        }
      });
    },
    // 获取数据
    getList() {
      this.loading = true;
      DeliveryManageApi.acceptanceTesting
        .page()
        .then(res => {
          if (res.status === 200) {
            this.tableData = [];
            this.tableData = res.data.data;
          } else {
            this.$message.error(res.statusText);
          }
        })
        .finally(() => (this.loading = false));
      let userdata = {
        size: 9999,
        current: 1,
        sort: "id",
        order: "descending",
        model: {
          nation: { key: "" },
          education: { key: "" },
          positionStatus: { key: "" },
          org: { key: null },
          station: { key: null },
          sex: { code: "" }
        },
        map: {},
        timeRange: null
      };
      userApi.page(userdata).then(response => {
        const res = response.data;
        if (res.isSuccess) {
          res.data.records.forEach(item => {
            if (item.id == this.$store.state.account.user.id) {
              this.basicData.receiveDepart = item.name;
              this.inExpData.deliveryDepart = item.name;
              this.inExpData.bloodArea = item.name;
            }
          });
        }
      });
    },
    // 点击实验验收
    clickCheck() {
      if (this.selectList.length == 0) {
        this.$message.error("请选择数据！");
        return;
      }
      if (this.selectList.length > 1) {
        this.$message.error("只能选择一条数据！");
        return;
      }
      this.dialog = true;
      this.yanshouTableShow = true;
      DeliveryManageApi.acceptanceTesting
        .selectSampleDetail({ deliveryId: this.selectList[0].deliveryId })
        .then(res => {
          if (res.status === 200) {
            this.dormitory = res.data.data.list;
            this.basicData.receiveDepart = res.data.data.departName;
            this.dormitory.forEach(item => {
              item.qualified = true;
              item.disqualificationReason = [];
            });
          } else {
            this.$message.error(res.statusText);
          }
        })
        .finally(() => (this.yanshouTableShow = false));
    },
    // 点击扫码验收
    clickShaneCheck() {
      this.showShane = true;
      this.dormitory = [];
    },
    // 点击导入数据按钮
    clickImportBut() {
      this.dormitory = [];
      this.importShow = true;
      let queryParams = {
        size: 10,
        current: 1,
        sort: "id",
        order: "descending",
        model: {
          nation: { key: "" },
          education: { key: "" },
          positionStatus: { key: "" },
          org: { key: null },
          station: { key: null },
          sex: { code: "" },
          account: this.$store.state.account.user.account
        },
        map: {},
        timeRange: null
      };
      // 获取用户组织
      userApi.page(queryParams).then(response => {
        const res = response.data;
        if (res.isSuccess) {
          this.inExpData.deliveryDepart = res.data.records[0].org.key;
          this.inExpData.deliveryId =
            new Date().getFullYear().toString() +
            ((new Date().getMonth() + 1).toString() < 10
              ? "0" + (new Date().getMonth() + 1).toString()
              : (new Date().getMonth() + 1).toString()) +
            (new Date().getDate().toString() < 10
              ? "0" + new Date().getDate().toString()
              : new Date().getDate().toString()) +
            new Date().getHours().toString() +
            new Date().getMinutes().toString() +
            new Date().getSeconds().toString();
          DeliveryManageApi.acceptanceTesting
            .inExpress(this.inExpData)
            .then(res => {
              this.importDeliveryId = res.data;
            });
        }
      });
    },
    // 点击分页
    handleSizeChange: function(val) {
      this.basicData.size = val;
      this.getList(this.basicData);
    },
    // 选择页码
    handleCurrentChange: function(currentPage) {
      this.basicData.current = currentPage;
      this.getList(this.basicData);
    },
    // 选中数据操作
    selectChanage(v) {
      this.selectList = v;
    },
    // 选中数据操作
    selectDormitoryChanage(v) {
      this.selectDormitoryList = v;
    },
    // 单击行
    clickRow(v) {
      this.$refs.dormitoryTable.toggleRowSelection(v); //选中
    },
    // 双击击行
    clickRows(v) {
      this.innerVisible = true;
      DeliveryManageApi.acceptanceTesting
        .getSampleId({ sampleId: v.sampleId })
        .then(res => {
          this.sampleData = res.data.data;
          this.orgTree.filter(res => {
            if (res.id == this.sampleData.areaId.key) {
              this.orgTreeC = res.children;
            }
          });
          this.orgTreeC.filter(res => {
            if (res.id == this.sampleData.hospitalId.key) {
              this.orgTreeCs = res.children;
            }
          });
          if (this.sampleData.experimentProject == null) {
            this.sampleData.experimentProject = [];
          }
        });
    },
    // 修改样本详情保存
    editSemperSave() {
      let that = this;
      DeliveryManageApi.acceptanceTesting
        .updSample(that.sampleData)
        .then(res => {
          if (res.status == 200) {
            that.yanshouTableShow = true;
            DeliveryManageApi.acceptanceTesting
              .selectSampleDetail({ deliveryId: that.selectList[0].deliveryId })
              .then(res => {
                if (res.status === 200) {
                  that.dormitory = res.data.data.list;
                  that.dormitory.forEach(item => {
                    item.qualified = true;
                    item.disqualificationReason = [];
                  });
                  that.innerVisible = false;
                } else {
                  that.$message.error(res.statusText);
                }
              })
              .finally(() => (that.yanshouTableShow = false));
          } else {
            that.$message.error(res.statusText);
          }
        });
    }
  },
  watch: {
    "basicData.receiveTime": function(v) {
      this.changeReceiveTime(v);
    },
    "sampleData.birthTime": function(v) {
      this.changeBirthTime(v, "b");
    },
    "sampleData.bloodTime": function(v) {
      this.changeBloodTime(v, "b");
    },
    "basicData.barCode": function(v, d) {
      if (this.showShane) {
        if (v.length == 11) {
          this.getscanReceive();
          setTimeout(() => {
            this.basicData.barCode = "";
          }, 1000);
        }
      }
    }
  }
};
</script>

<style lang="less">
.flex {
  display: flex;
  align-items: center;
  justify-content: center;
}
#more-row {
  .remark {
    width: 100%;
    .el-form-item__content {
      width: 90%;
    }
  }
  #shiyan {
    .projectIdList {
      width: 100%;
      .el-form-item__content {
        width: 80%;
      }
    }
  }
}
.mores {
  margin: 10px 0;
  .flex;
  justify-content: flex-start;
  width: 100%;
  background: #188ff233;
  height: 30px;
  padding: 5px 8px;
  .more-title {
    font-family: SourceHanSansSC;
    font-style: normal;
    letter-spacing: 0px;
    line-height: 20px;
    text-decoration: none;
    margin-right: 1rem;
    font-size: 14px;
    font-weight: 500;
    color: #000;
  }
}
.edit-sample {
  .el-form-item__content,
  .el-date-editor,
  .el-select,
  .el-textarea {
    width: 100% !important;
  }
}
#TesTing {
  .el-form-item__content,
  .el-date-editor,
  .el-select,
  .el-textarea {
    width: 100% !important;
  }
  .el-form-item__label {
    text-align: left !important;
  }
  #dialog-testing {
    display: flex;
    justify-content: center;
    align-items: center;
    .el-dialog {
      margin-top: 0 !important;
    }
    .el-form-item {
      padding-left: 1.5vw;
    }
  }

  #dialog-testing-daoru {
    .el-form {
      width: 100%;
      .el-form-item {
        padding-left: 1.5vw;
      }
    }
  }
  .el-dialog__header {
    .flex;
    background: #2669f3;
    .el-dialog__title {
      color: #fff;
    }
    .el-dialog__headerbtn .el-dialog__close {
      color: #ffffff;
    }
  }
  .el-dialog__body {
    .flex;
    flex-direction: column;
    .top-list {
      width: 100%;
      display: flex;
      justify-content: flex-start;
      .col {
        margin: 5px 0;
      }
    }
  }
  .acceptance-dialog {
    max-height: 265px;
    overflow: auto;
  }
  .import-table {
    .el-table__body-wrapper {
      max-height: 400px;
      overflow-y: auto;
    }
    @media screen and (max-width: 1400px) {
      .el-table__body-wrapper {
        max-height: 200px;
        overflow-y: auto;
      }
    }
  }
}
</style>
